<?php
/**
 * 公用控制器类
 */
class CommonAction extends Action{
	/**
	 * 自动执行方法
	 */
	public function _initialize(){

		if(isset($_COOKIE['auto']) && !isset($_SESSION['uid'])){
			$value=base64_decode($_COOKIE['auto']);
			$name=$value^md5(C('AUTO_KEY'));
			if($user=M('admin')->where(array('username'=>$name))->find()){
				
				session('uid',$user['id']);
				session('username',$user['username']);
			}
		}	
		if(!isset($_SESSION['uid']) || !isset($_SESSION['username'])){
			redirect(U('Login/index'));
		}
	}
}
?>